package org.sport.repository;

import org.sport.model.entityModel.LinkmantableEntity;
import org.sport.model.entityModel.ParacttableEntity;
import org.sport.model.entityModel.UsertableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface LinkmantableRepository extends JpaRepository<LinkmantableEntity,Integer> {


    @Transactional
    @Query("select lin from LinkmantableEntity lin where lin.usertableByOwnerId =?1 and lin.usertableByUserId=?2")
    public LinkmantableEntity findOne(UsertableEntity owner,UsertableEntity user);


    @Transactional
    @Query("select lin from LinkmantableEntity lin where lin.usertableByOwnerId =?1")
    public List<LinkmantableEntity> findUserList(UsertableEntity owner);
}
